<template>
    <div class="bookitem" @click.stop="checklogin(item.url)">
        <div class="head"><img :src="item.bookimg"></div>
        <div class="body">
            <div class="title">{{item.bookname}}</div>
            <div class="info">{{item.bookdescription}}</div>
        </div>
        <div class="foot">
            <van-tag plain type="primary">{{item.classfy}}</van-tag>
            <p class="price"><span class="oldprice">{{item.oldprice}}元</span><span>￥{{item.newprice}}元</span></p>
        </div>
    </div>
</template>

<script>
    export default {
        props:{
            item:{ type: Object, default: () => {} },
        },
        name: "bookcard",
        data () {
            return {
            }
        },
        created(){
        },
        computed:{
            userdata(){
                return this.$store.getters.userdata ? this.$store.getters.userdata : '';
            },
        },
        methods: {
            checklogin(url) {
                var that = this
                if (!that.userdata) {
                    that.$dialog.confirm({
                        title: '提示', message: '请先登录', confirmButtonText: '前往登陆', cancelButtonText: '取消'
                    }).then(() => {
                        this.$router.push({ path: '/user/login' });
                    }).catch(() => {
                    });
                    return
                }
                window.location.href = url
            },
        }
    };
</script>

<style scoped>
</style>